<template>
  <div class="page">
    用户ID:{{$route.params.id}}
    {{user.name}}
  </div>
</template>

<script type="text/ecmascript-6">
export default {
  async asyncData({ params, $axios }) {
    //注意返回的是响应数据
    const data = await $axios.$get(`/api/users/${params.id}`);
    if (data.ok) {
      return { user: data.user };
    }
    error({ statusCode: 400, message: "id有误，查询失败" });
  },
  data() {
    return {};
  },
  components: {}
};
</script>

<style scoped>
</style>
